<p>This tests CreateLink for caret selections.  A link containing the url text should be inserted.</p>
<div contenteditable="true" id="div">There should be a link between these two braces: {}</div>
<p id="console"></p>

<script>

if (window.testRunner)
    testRunner.dumpAsText();

function log(message) {
    var console = document.getElementById("console");
    var text = document.createTextNode(message);
    console.appendChild(text);
}

var div = document.getElementById("div");
var text = div.firstChild;
var selection = window.getSelection();
selection.collapse(text, text.length - 1);

document.execCommand("CreateLink", false, "http://www.apple.com/");

log(div.innerHTML);

</script>
